const test = [1, 2, 3];

const res = Object.keys(test);

console.log(res, test[res[0]]);

const debounce = (fn, wait = 1000) => {
  let timer = null;

  return (...args) => {
    if (timer) {
      clearTimeout(timer);
    }
    timer = setTimeout(() => {
      fn(...args);
    }, wait);
  };
};

const timer = setInterval(
  debounce(() => console.log(1)),
  10
);
setTimeout(() => {
  clearInterval(timer);
}, 2000);

const throttle = (fn, wait = 1000) => {
  let lastTime = 0;

  return (...args) => {
    const now = Date.now();
    if (now - lastTime > wait) {
      fn(...args);
      lastTime = now;
    }
  };
};

setInterval(
  throttle(() => console.log(1)),
  10
);

const numbers = [65, 44, 12, 4];

const res2 = numbers.reduce((pre, cur) => {
  console.log('pre -- ', pre, cur);
  return pre + cur;
}, 2);
numbers.map((item, index, array) => {});
console.log(res2);
